# 让对象沿着指定的曲线移动
from pygame_test.MoveRect import MoveRect
import pygame
import sys
import math


def move_alone_line():
    x = 0
    y = 0.5
    r1 = MoveRect(x, y, 2, 2, pygame.Color('red'))

    pygame.init()
    s = pygame.display.set_mode((150,150))
    fclock = pygame.time.Clock()
    i = 1
    while True:
        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
        # s.fill((0,0,0))
        r1.draw(s)
        i +=1
        r1.x = 150-i*10
        r1.y = 150-f(i)
        pygame.display.update()
        fclock.tick(1)

def f(x):
    # return math.log10(x)
    return x**2+2
    # return math.asin(x)

if __name__ == '__main__':
    move_alone_line()
    # for i in range(100):
    #     x = i
    #     y = f(x)
    #     print(x,y)
